package game;

import java.io.Serializable;

public class Player implements Serializable {
	private String name;
	private int xpos;
	private int ypos;
	private int point;
	private String direction;

	/**
	 * 
	 * @param name
	 */
	public Player(String name) {
		this.name = name;
		xpos = 9;
		ypos = 7;
		point = 0;
		direction = "up";
	}

	/**
	 * 
	 * @return
	 */
	public int getXpos() {
		return xpos;
	}

	/**
	 * 
	 * @param xpos
	 */
	public void setXpos(int xpos) {
		this.xpos = xpos;
	}

	/**
	 * 
	 * @return
	 */
	public int getYpos() {
		return ypos;
	}

	/**
	 * 
	 * @param ypos
	 */
	public void setYpos(int ypos) {
		this.ypos = ypos;
	}

	/**
	 * 
	 * @return
	 */
	public String getDirection() {
		return direction;
	}

	/**
	 * 
	 * @param direction
	 */
	public void setDirection(String direction) {
		this.direction = direction;
	}

	public String getName() {
		return this.name;
	}
	
	/**
	 * 
	 */
	@Override
	public String toString() {
		return "Navn: " + name + ", point: " + point + ", x/y: " + this.xpos + "/" + this.ypos;
	}

	/**
	 * 
	 */
	public void addOnePoint() {
		point++;
	}

	/**
	 * 
	 */
	public void subOnePoint() {
		point--;
	}
	
	public void setPoint(int point) {
		this.point = point;
	}

	public int getPoint() {
		return this.point;
	}
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Player other = (Player) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}
}
